<?php

namespace app\company\service;

use app\model\AppModel;
use sword\Cache\Facade\Cache;

class Base
{

    const APP_KEY = 'company';

    /**
     * 获取当前AppID
     * @return ?int
     */
    protected function getAppid(): ?int
    {
        $key = self::APP_KEY;
        $expire = 3600;
        $cacheKey = "app_id_form_key:{$key}_$expire";
        return Cache::remember($cacheKey, function () use($key){
            return AppModel::where('key', $key)->value('id');
        }, $expire);
    }

}